package com.yswl.pri.guide.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.yswl.pri.R;
import com.yswl.pri.home.Website;

import yswl.com.klibrary.base.BaseRecyclerAdapter;
import yswl.com.klibrary.base.BaseViewHolder;
import yswl.com.klibrary.util.MTextViewUtil;


public class MyAdapter extends BaseRecyclerAdapter<Website> {
    View.OnClickListener mOnClickListener;

    public MyAdapter(Context mContext, int itemLayoutId, View.OnClickListener onClickListener) {
        super(mContext, itemLayoutId);
        mOnClickListener = onClickListener;
    }

    @Override
    public void onBind(BaseViewHolder holder, Website website, int position) {
        ImageView mIv = (ImageView) holder.findById(R.id.guide_item_iv);
        TextView mType = (TextView) holder.findById(R.id.tv_type);
        if (TextUtils.isEmpty(website.type)) {
            mType.setVisibility(View.GONE);
        } else {
            mType.setText(website.type);
        }
        TextView name = (TextView) holder.findById(R.id.name);
        Glide.with(mWeakContext.get()).load(website.icon).into(mIv);
        MTextViewUtil.setText(name, website.name);
        holder.itemView.setOnClickListener(mOnClickListener);
        holder.itemView.setTag(position);
    }


}
